package com.huawei.appgallery.forum.cards.card;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ListView;
import com.huawei.appgallery.forum.base.card.ForumCard;
import com.huawei.appgallery.forum.cards.bean.FeedRecommendItemBean;
import com.huawei.appgallery.forum.cards.bean.ForumFeedRecommendCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import o.azb;
import o.bsp;
import o.bsy.b;
import o.bsy.c;
import o.cgz;
import o.epr;
import o.epv;

public class ForumFeedRecommendCard extends ForumHorizonCard {
    private View ʻ;
    private int ʼ;
    private ViewStub ʽ;
    private View ˊॱ;
    private ListView ᐝ;

    class a extends a {
        final /* synthetic */ ForumFeedRecommendCard ˊ;

        class e extends a {
            final /* synthetic */ a ʻॱ;
            private ForumFeedRecommendItemCard ॱᐝ;

            public e(a aVar, View view) {
                this.ʻॱ = aVar;
                super(aVar, view);
                this.ॱˋ = view;
                this.ॱᐝ = new ForumFeedRecommendItemCard(view.getContext());
                this.ॱᐝ.ˏ(view);
                this.ॱᐝ.ˉ().setClickable(true);
            }
        }

        private a(ForumFeedRecommendCard forumFeedRecommendCard) {
            this.ˊ = forumFeedRecommendCard;
            super(forumFeedRecommendCard);
        }

        protected a ˊ(ViewGroup viewGroup, int i) {
            View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(b.ˋ, viewGroup, false);
            inflate.getLayoutParams().width = this.ˊ.ʼ;
            return new e(this, inflate);
        }

        protected void ˎ(a aVar, int i) {
            ForumFeedRecommendCardBean forumFeedRecommendCardBean = (ForumFeedRecommendCardBean) this.ˊ.ˊᐝ;
            if (aVar instanceof e) {
                CardBean cardBean = (CardBean) forumFeedRecommendCardBean.ˊ().get(i);
                cardBean.ˋˋ(forumFeedRecommendCardBean.ॱˉ());
                ((FeedRecommendItemBean) cardBean).ˍ(forumFeedRecommendCardBean.ॱˈ());
                ((e) aVar).ॱᐝ.ˏ(cardBean);
            }
        }

        public int ˏ() {
            CardBean ˌ = this.ˊ.ˌ();
            if (ˌ instanceof ForumFeedRecommendCardBean) {
                ForumFeedRecommendCardBean forumFeedRecommendCardBean = (ForumFeedRecommendCardBean) ˌ;
                if (forumFeedRecommendCardBean.ˊ() != null) {
                    return forumFeedRecommendCardBean.ˊ().size();
                }
            }
            return 0;
        }
    }

    public /* synthetic */ cgz ˏ(View view) {
        return ˎ(view);
    }

    public ForumFeedRecommendCard(Context context) {
        super(context);
    }

    public void ˊ(ListView listView) {
        this.ᐝ = listView;
    }

    public ForumCard ˎ(View view) {
        super.ˎ(view);
        azb.ˏ(view, c.ˎ);
        this.ʽ = (ViewStub) view.findViewById(c.ᐝॱ);
        azb.ˏ(this.ʽ);
        this.ˊॱ = view.findViewById(c.ʻॱ);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        if (cardBean instanceof ForumFeedRecommendCardBean) {
            ForumFeedRecommendCardBean forumFeedRecommendCardBean = (ForumFeedRecommendCardBean) cardBean;
            if (forumFeedRecommendCardBean.ˎ()) {
                if (this.ʻ == null) {
                    this.ʻ = this.ʽ.inflate();
                }
                this.ʽ.setVisibility(0);
                if (this.ᐝ != null) {
                    if (bsp.ˋ()) {
                        LayoutParams layoutParams = (LayoutParams) this.ʻ.getLayoutParams();
                        if (layoutParams == null) {
                            layoutParams = new LayoutParams(-1, -2);
                        }
                        layoutParams.height = epv.ˋ(this.ˊˋ.getContext(), 202);
                    } else if (this.ˊˋ.getLayoutParams() != null) {
                        this.ˊˋ.getLayoutParams().height = this.ᐝ.getHeight();
                    }
                }
                this.ˊॱ.setVisibility(8);
                return;
            }
            this.ʽ.setVisibility(8);
            if (this.ˊˋ.getLayoutParams() != null) {
                this.ˊˋ.getLayoutParams().height = -2;
            }
            if (forumFeedRecommendCardBean.ॱㆍ()) {
                this.ˊॱ.setVisibility(8);
            } else {
                this.ˊॱ.setVisibility(0);
            }
        }
    }

    protected void ˎ() {
        int i = 4;
        if (epr.ˎ().ॱॱ()) {
            if (bsp.ˋ()) {
                i = 6;
            }
        } else if (!bsp.ˋ()) {
            i = 3;
        }
        this.ʼ = (azb.ॱ(this.ʼॱ) - (this.ˎ.ॱ() + (this.ˎ.ॱॱ() * (i + 2)))) / i;
    }

    protected androidx.recyclerview.widget.RecyclerView.a ᐝ() {
        return new a();
    }
}
